/**  

* <p>Title: CategoryController.java</p>  

* <p>Description: </p>  

* <p>Company: ���ƿƼ�</p>  

* @author javafengyu  

* @date 2019��4��12��  

* @version 1.0  

*/  
package com.zb.web.controller;

import com.zb.model.TCategory;
import com.zb.model.TGoods;
import com.zb.service.impl.CategoryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**  

* <p>Title: CategoryController</p>  

* <p>Description: </p>  
*/
@Controller
@RequestMapping("/web")
public class CategoryController {

	@Autowired
	private CategoryServiceImpl cs;
	

	@RequestMapping("/SelectGoodsByCategory")
	public String selectGoodsByCategory(String cateName,Map goodsMap) {
		List<TGoods> list=cs.selectGoodsByCateIdService(cs.selectCateIdByNameService(cateName));
		goodsMap.put("goodsList",list );
		return"homePage";
	}
	

	@RequestMapping("/SelectCategory")
	public void selectCategory(HttpSession session,HttpServletResponse response) {
		List<TCategory> catelist=cs.selectCate();
		session.setAttribute("cateList", catelist);
		try {
			response.sendRedirect("SelectGoods");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//return"homePage";
	}
	
	/**
	 * @param goods_dimSearch
	 * @param session
	 * @return
	 */
	@RequestMapping("/DimSearch")
	public String DimSearch(String goods_dimSearch,HttpSession session) {
		List<TGoods> list=cs.dimSelectService(goods_dimSearch);
		System.out.println("查询到的数据信息为："+list);
		session.setAttribute("dimgoods", list);
		return "item_sale_page";
	}
}
